<%@page import="com.feib.soeasy.util.CodeTableUtil"%>
<%@page import="com.feib.soeasy.model.UploadFile"%>
<%@page language="java" pageEncoding="UTF-8" contentType="text/html;charset=utf-8"%>
<%@include file="/includes/taglibs.jsp"%>
<%@page import="com.feib.soeasy.util.UserUtil"%>

<c:choose>
	<c:when test="${null != actionBean.queryResult && not empty actionBean.queryResult}">
		<table id="listTable">
			<thead>
				<tr>
					<th></th>
					<th>上傳日期</th>
					<th>檔案名稱</th>
					<th>上傳格式</th>
					<th>上傳人員</th>
					<th>總筆數</th>
					<th>總金額</th>
					<%if ( UserUtil.isBankGroup()){ %>
					<th>業者名稱</th>
					<%} %>
					<th></th>
				</tr>
			</thead>
			<tbody>
				<c:forEach items="${actionBean.queryResult}" var="viewObj" varStatus="rowstat">
				<tr>
					<td>
						<input type="radio" id="radioUploadFile-<c:out value='${viewObj.uploadFile.uploadFilePk}'/>" name="radioUploadFile">
					</td>
					<td align="center"><fmt:formatDate value="${viewObj.uploadFile.uploadDate}" pattern="yyyy/MM/dd" /><br/>
						<fmt:formatDate value="${viewObj.uploadFile.uploadDate}" pattern="HH:mm:ss" />
					</td>
					<td><c:out value="${viewObj.uploadFile.fileName}"/></td>
					<td><c:out value="${viewObj.uploadFile.formatDefinition.formatName}"/></td>
					<td><c:out value="${viewObj.uploadFile.uploadUser.userName}"/></td>
					<td align="right"><fmt:formatNumber value="${viewObj.totalCount}" pattern="##,###" /></td>
					<td align="right"><fmt:formatNumber value="${viewObj.sumAmount}" pattern="##,###" /></td>
					<%if ( UserUtil.isBankGroup()){ %>
					<td><c:out value="${viewObj.uploadFile.group.groupName}" /></td>
					<%} %>
					<td>
						<div id="viewUploadFileImg-<c:out value='${viewObj.uploadFile.uploadFilePk}'/>"><a href="javascript: void(0)" class="btnZoom">查詢</a></div>
					</td>			
				</tr>
				</c:forEach>
			</tbody>
		</table>
		<script type="text/javascript">
		<!--
		$(document).ready(function() {
		
			$("[id^='radioUploadFile-']").click(function() {
				var uploadFilePk = this.id.substring(16);
				$('#hidden\\.uploadFilePk').val(uploadFilePk);
				
			});
			
			$("[id^='viewUploadFileImg-']").click(function() {
				var uploadFilePk = this.id.substring(18);		
				doQueryPaymentsAction(uploadFilePk , 1);
				
			});
			
			$("[id^='doDownloadFile']").click(function() {
				
			});
		});
		
			function checkUploadFileRadio()
			{
				var uploadFilePk = $('#hidden\\.uploadFilePk').val();
				var qryPaymentStatus = $('#qryPaymentStatus').val();
				$('#hidden2\\.qryPaymentStatus').val(qryPaymentStatus);
				if(uploadFilePk == '')
				{
					alert('請選擇下載帳單!!');
					return false;
				}
			}
		//-->
		</script>
		
		<stripes:form id="queryUploadFileFrom" beanclass="com.feib.soeasy.action.Soez1018ActionBean" 
			method="post">
			<table id="listTable" width="100%">
				<tr align="center">
					<td>
						<stripes:submit id="doDownloadUploadFileAction" name="doDownloadUploadFileAction"  value="下載明細資料(TXT)"
						onclick="return checkUploadFileRadio();"/>
						
						<stripes:submit id="doDownloadUploadFileForCsv" name="doDownloadUploadFileForCsv"  value="下載明細資料(CSV)"
						onclick="return checkUploadFileRadio();"/>
						<stripes:hidden id="hidden.uploadFilePk" name="uploadFilePk"/>
						<stripes:hidden id="hidden2.qryPaymentStatus" name="qryPaymentStatus"/>
					</td>
				</tr>
			</table>
		</stripes:form>
		
	</c:when>
	<c:otherwise>
		<div id="queryNothingBlockDiv" style="display: none;">
			查無資料
		</div>		
		<script type="text/javascript">
		<!--
		$(document).ready(function() {
			$( "#queryNothingBlockDiv" ).dialog( "destroy" );
			$( "#queryNothingBlockDiv" ).dialog({  title:'<%=UserUtil.getCurrentMenuItemName() %>' ,width: 300, resizable: false, modal: true, buttons : {
				Ok : function() {
					$(this).dialog("close");
				}
			}  });
		});
		//-->
		</script>
	</c:otherwise>
</c:choose>